Skip to content

Comments

Guard controller#1238

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
ingvagabund:guard-controller
Dec 17, 2021
Merged

Guard controller#1238
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
ingvagabund:guard-controller

Conversation

@ingvagabund
Copy link
Member

@ingvagabund ingvagabund commented Oct 27, 2021

Deploy guarding pods with a PDB which will make sure a node does not drain a node until at most one replica of an operand is unavailable. Each guarding pod checks healthz status of an operand on the same node.

The guard controller repeatedly checks available master nodes and for each one renders an unmanaged guard pod. Each guard pod is responsible for checking if corresponding operand (operand pod running on the same node as the guard pod) is ready (through checking the /healthz endpoint). The guard uses an https probe to check readiness of its operand. At the same time a pdb with minAvailable set to len(masters)-1 is rendered. Each time the number of master nodes changes, the minAvailable field is updated accordingly.

Outstanding facts:

  • guard pod has its nodename set directly (in case the KS is down)
  • the Guard controller can delete pods (in case image/probe host changes)
  • the Guard controller requires create/delete condition checkers (in case the number of master nodes is scaled to 1 to remove the PDB)

Applied and tested in:

} else {
_, result.Changed, result.Error = DeleteStorageVersionMigration(ctx, clients.migrationClient, recorder, t)
}
case *unstructured.Unstructured:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that in combination with a RESTMapper, we'd be able to delete any manfiest we can read with a one to one mapping of resources to kind.

Doesn't have to be in this PR, but seems like a valuable future thing.

@deads2k
Copy link
Contributor

deads2k commented Nov 1, 2021

move Allow resource deletion based on a certain condition to its own commit so I can merge it

@ingvagabund ingvagabund force-pushed the guard-controller branch 2 times, most recently from 50af26a to 1d58cbd Compare November 10, 2021 15:29
@ingvagabund
Copy link
Member Author

/retest

Copy link

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some questions, in general this looks good.

@@ -0,0 +1,313 @@
// Code generated for package bindata by go-bindata DO NOT EDIT. (@generated)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my, we got rid of go-bindata from all the operators but library-go is still left with one 😞 we'll should fix that...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will require more changes. Better to do it in another PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a separate PR, just an observation 😉

for _, node := range nodes {
if _, exists := operands[node.Name]; !exists {
klog.Errorf("Missing operand on node %v", node.Name)
errs = append(errs, fmt.Errorf("Missing operand on node %v", node.Name))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During reboots or similar problems we'll be throwing a lot of errors, I don't think that's the intention. Shouldn't we filter out NotReady nodes earlier in the node query? IIRC installer ignores not ready nodes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. In case the operand pod does not exist, I will skip in case the underlying node is not ready. That might help reduce the number of errors. Also, once a node condition changes, the sync loop gets triggered again so no need to return an error here.

pdbGetter: pdbGetter,
installerPodImageFn: getInstallerPodImageFromEnv,
createConditionalFunc: createConditionalFunc,
deleteConditionalFunc: deleteConditionalFunc,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at openshift/cluster-kube-scheduler-operator#373 I see this is only used for SNO check, any other particular reason you want to split into create and delete condition? If that's only SNO, why not having a single check?

Copy link
Member Author

@ingvagabund ingvagabund Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since create is not always of !delete (not delete). Also openshift/cluster-kube-controller-manager-operator#568 (comment)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but returning bool, errror tuple is an option you also mention there.


klog.V(5).Infof("Rendering guard pod for operand %v on node %v", operands[node.Name].Name, node.Name)

pod := resourceread.ReadPodV1OrDie(bindata.MustAsset(filepath.Join("pkg/operator/staticpod/controller/guard", "manifests/guard-pod.yaml")))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a lot of unnecessary reads, why not just read it once when we create the controller and then just update the internal representation as needed and apply.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bindata.MustAsset already has the internal representation as it is. So it's just a convenient wrapper around it.

Copy link

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits about ConditionalFunc, but those can be either addressed in followup or I can be overruled by majority 😉
/hold

/lgtm

return utilerrors.NewAggregate(errs)
}

func WithIsSNOCheck(infraLister configv1listers.InfrastructureLister, neg bool) resourceapply.ConditionalFunction {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need neg parameter to negate the result, it's not that hard to add ! before the invocation, is it?

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 7, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 7, 2021
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 8, 2021
Copy link

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 8, 2021
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@ingvagabund
Copy link
Member Author

/retest

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

15 similar comments
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@ingvagabund
Copy link
Member Author

Something changed meantime

pkg/operator/staticpod/controller/guard/guard_controller_test.go:379:7: unknown field 'Handler' in struct literal of type "k8s.io/api/core/v1".Probe
FAIL	github.com/openshift/library-go/pkg/operator/staticpod/controller/guard [build failed]

@ingvagabund
Copy link
Member Author

Handler renamed to ProbeHandler

Deploy guarding pods with a PDB which will make sure a node does not
drain a node until at most one replica of an operand is unavailable.
Each guarding pod checks healthz status of an operand on the same node.
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2021
Copy link

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 17, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, ingvagabund, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants